package com.example.springbootdemo.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class AppRunnable implements ApplicationRunner {

    private final ApiKeyContext apiKeyContext;

    public AppRunnable(ApiKeyContext apiKeyContext) {
        this.apiKeyContext = apiKeyContext;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        apiKeyContext.updateApiKey();
    }
}
